package com.rules.admin.login;


import com.rules.admin.utils.RequestAndResponseContextHolder;
import com.rules.admin.vo.RuleUser;


import javax.servlet.http.HttpSession;

public class SessionUserHolder implements UserHolder<RuleUser> {
   public void holdUser(RuleUser ruleUser) {
      HttpSession session = RequestAndResponseContextHolder.request().getSession();
      session.setAttribute("user", ruleUser);
   }

   public RuleUser getUser() {
      HttpSession session = RequestAndResponseContextHolder.request().getSession();
      return (RuleUser)session.getAttribute("user");
   }

   public void destroy() {
      HttpSession session = RequestAndResponseContextHolder.request().getSession();
      session.removeAttribute("user");
   }
}
